package net.learn.vocabulary;

import java.util.Random;

import org.xmlpull.v1.XmlPullParser;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.Toast;

public class quiz extends Activity {
	public EditText text1;
	public EditText text2;
	public Button m_bNext;
	public Button m_bMean;
	public Lesson lesson;
	public Context mContext;
	public int m_random;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.quiz);
		mContext = getBaseContext();
		lesson = struct.curlesson;
		LayoutParams mp;
        mp = new LayoutParams(Main.text_width, Main.text_height);
        mp.gravity = 0x11;
        
        text1 = (EditText)findViewById(R.id.editText1);
        text1.setLayoutParams(mp);
        text1.setGravity(0x11);
        text1.setTextSize((float)Main.text_size);
        text1.setFocusable(false);
        
        text2 = (EditText)findViewById(R.id.editText2);
        text2.setLayoutParams(mp);
        text2.setGravity(0x11);
        text2.setTextSize((float)Main.text_size);
        text2.setFocusable(false);

        m_bNext = (Button)findViewById(R.id.Next);
        m_bMean = (Button)findViewById(R.id.Mean);
        m_bNext.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Random ran = new Random();
				m_random = ran.nextInt(lesson.Length());
				text1.setText(lesson.Word(m_random));
				
	
			}
		});
        m_bMean.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				text2.setText(lesson.Mean(m_random));
			}
		});
	}

}
